<%-- 
    Document   : display_posts_by_type
    Created on : 2 Jun, 2012, 10:42:56 PM
    Author     : bharat
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="./css/maincss.css">
        <link rel="stylesheet" type="text/css" href="./css/myaccountcss.css">
        <title>JSP Page</title>
    </head>
    <body>
        <div class="container">
            <div class="header">
                ONLINE COLLEGE MAGAZINE
            </div>
            <div class="navigation_menu">
                <%@include file="navigationmenu.jsp"%>
            </div>

            <div class="slab">
                <%
                    String pid_ = request.getParameter("pid");

                    Connection con6 = null;
                    PreparedStatement pstmt6 = null;
                    ResultSet rs6 = null;

                    try {

                        Class.forName("oracle.jdbc.driver.OracleDriver");
                        con6 = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "aksh", "aksh");

                        pstmt6 = con6.prepareStatement("select type, subject, post, dop, postedby from posts where pid=?");
                        pstmt6.setString(1, pid_);
                        rs6 = pstmt6.executeQuery();
                %>
                <table>
                    <%
                        while (rs6.next()) {
                    %>                                      
                    <tr>
                        <td>
                            <%=rs6.getString(3)%>
                        </td>
                    </tr>
                    <tr>
                        <td style="background-color: #DED189">
                            Type: <%=rs6.getString(1)%> Posted on: <%=rs6.getString(4)%> Posted by: <%=rs6.getString(5)%>
                        </td>
                    </tr>
                    <%
                        }
                    %>
                </table>
                <%

                    } catch (Exception e) {
                        response.sendError(505, e.getMessage());
                        e.printStackTrace();
                    }

                %>
            </div>

            <div class="login">
                <%@include file="types_anchored.html" %>
            </div>
            <div class="sidebar">
                <%
                    String type_ = request.getParameter("type");
                    out.println(type_);


                    Connection con7 = null;
                    PreparedStatement pstmt7 = null;
                    ResultSet rs7 = null;

                    try {

                        Class.forName("oracle.jdbc.driver.OracleDriver");
                        con7 = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "aksh", "aksh");

                        pstmt7 = con7.prepareStatement("select type, pid, subject from posts where type=? order by dop desc");
                        pstmt7.setString(1, type_);
                        rs7 = pstmt7.executeQuery();
                %>
                <table>
                    <%
                        while (rs7.next()) {
                    %>                                      
                    <tr><td>
                            <a href="display_post_by_type_when_clicked.jsp?pid=<%=rs7.getString(2)%>&type=<%=rs7.getString(1)%>"><%=rs7.getString(3)%></a>
                        </td></tr>
                        <%
                            }
                        %>
                </table>
                <%

                    } catch (Exception e) {
                        response.sendError(505, e.getMessage());
                        e.printStackTrace();
                    }

                %>
            </div>
            <div class="footer">
                FOOTER
            </div>
        </div>
    </body>
</html>

